<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Registers a monitoring event subscriber globally</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="ref.monitoring.functions.html">« 函数</a></li>
      <li style="float: right;"><a href="function.mongodb.driver.monitoring.removesubscriber.html">MongoDB\Driver\Monitoring\removeSubscriber »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.monitoring.functions.html">函数</a></li>
    <li>Registers a monitoring event subscriber globally</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.mongodb.driver.monitoring.addsubscriber" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\Monitoring\addSubscriber</h1>
  <p class="verinfo">(mongodb &gt;=1.3.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\Monitoring\addSubscriber</span> &mdash; <span class="dc-title">Registers a monitoring event subscriber globally</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.mongodb.driver.monitoring.addsubscriber-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>MongoDB\Driver\Monitoring\addSubscriber</strong></span>(<span class="methodparam"><span class="type"><a href="class.mongodb-driver-monitoring-subscriber.html" class="type MongoDB\Driver\Monitoring\Subscriber">MongoDB\Driver\Monitoring\Subscriber</a></span> <code class="parameter">$subscriber</code></span>): <span class="type"><span class="type void">void</span></span></div>

  <p class="para rdfs-comment">
   Registers a monitoring event subscriber globally. The subscriber will be
   notified of all events in the driver for any Manager.
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <span class="simpara">
    If <code class="parameter">subscriber</code> is already registered globally, this
    function is a no-op. If <code class="parameter">subscriber</code> is also registered
    with one or more Managers, it will still only be notified once of each event
    for each Manager.
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mongodb.driver.monitoring.addsubscriber-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">subscriber</code> (<span class="type"><a href="class.mongodb-driver-monitoring-subscriber.html" class="type MongoDB\Driver\Monitoring\Subscriber">MongoDB\Driver\Monitoring\Subscriber</a></span>)</dt>

    <dd>

     <p class="para">
      A monitoring event subscriber to register globally.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mongodb.driver.monitoring.addsubscriber-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.mongodb.driver.monitoring.addsubscriber-errors">
  <h3 class="title">错误／异常</h3>
  <ul class="simplelist">
   <li class="member">Throws <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.html" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span> on argument parsing errors.</li>
  </ul>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mongodb.driver.monitoring.addsubscriber-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li class="member"><span class="function"><a href="function.mongodb.driver.monitoring.removesubscriber.html" class="function" rel="rdfs-seeAlso">MongoDB\Driver\Monitoring\removeSubscriber()</a> - Unregisters a monitoring event subscriber globally</span></li>
   <li class="member"><span class="interfacename"><a href="class.mongodb-driver-monitoring-subscriber.html" class="interfacename">MongoDB\Driver\Monitoring\Subscriber</a></span></li>
   <li class="member"><span class="interfacename"><a href="class.mongodb-driver-monitoring-commandsubscriber.html" class="interfacename">MongoDB\Driver\Monitoring\CommandSubscriber</a></span></li>
   <li class="member"><span class="function"><a href="mongodb-driver-manager.addsubscriber.html" class="function" rel="rdfs-seeAlso">MongoDB\Driver\Manager::addSubscriber()</a> - Registers a monitoring event subscriber with this Manager</span></li>
   <li class="member"><a href="mongodb.tutorial.apm.html" class="xref">Application Performance Monitoring (APM)</a></li>
  </ul>
 </div>


</div></div></div></body></html>